home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / redakcyjne / programy / Weather Watcher Live 6.1.23 / WWL6123.exe / {app} / Skins / Interface / Splendid2 / Includes / Splendid.js < prev   
Text File  |  2009-12-27  |  27KB  |  757 lines

  1. var windArrowDirection = "S";
  2. var lastWindDirection;
  3.  
  4. //***************************************************
  5. //*  Prevent from highlighting text in web browser  *
  6. //***************************************************
  7. document.onselectstart = new Function ("var controlType = (document.selection.createRange()).parentElement().nodeName.toUpperCase(); return controlType == 'INPUT'");
  8.  
  9.  
  10. //*********************************************
  11. //*  Used to interact with the WWL interface  *
  12. //*********************************************
  13. function setRunAction(action)
  14. {    document.getElementById("WW-RunAction").innerHTML = action;
  15. }
  16.  
  17. //***************************
  18. //*  Bottom menu functions  *
  19. //***************************
  20. var newsMenuOpen = false;
  21. var healthMenuOpen = false;
  22. var videosMenuOpen = false;
  23. var photosMenuOpen = false;
  24. var camerasMenuOpen = false;
  25.  
  26. function showMenu(menuName)
  27. {    hideAllMenus(menuName);            
  28.     document.getElementById(menuName).style.display="";
  29.     
  30.     switch (menuName) 
  31.     {    case "WW-NewsMenu":
  32.             newsMenuOpen = true;
  33.             break;
  34.         case "WW-HealthMenu":
  35.             healthMenuOpen = true;
  36.             break;
  37.         case "WW-VideosMenu":
  38.             videosMenuOpen = true;
  39.             break;
  40.         case "WW-PhotosMenu":
  41.             photosMenuOpen = true;
  42.             break;
  43.         case "WW-CamerasMenu":
  44.             camerasMenuOpen = true;
  45.             break;
  46.     }
  47. }
  48.  
  49. function hideMenu(menuName)
  50. {    switch (menuName) 
  51.     {      case "WW-NewsMenu": 
  52.             if (newsMenuOpen == false) 
  53.              {    document.getElementById('WW-NewsMenu').style.display='none';
  54.                  document.getElementById('WW-NewsMenuImg').src='../../Images/Links/NewsOff.gif'; 
  55.             }
  56.              break;
  57.         case "WW-HealthMenu": 
  58.             if (healthMenuOpen == false) 
  59.              {    document.getElementById('WW-HealthMenu').style.display='none';
  60.                  document.getElementById('WW-HealthMenuImg').src='../../Images/Links/HealthOff.gif'; 
  61.              }
  62.              break;        
  63.         case "WW-VideosMenu": 
  64.             if (videosMenuOpen == false) 
  65.              {    document.getElementById('WW-VideosMenu').style.display='none';
  66.                  document.getElementById('WW-VideosMenuImg').src='../../Images/Links/VideosOff.gif'; 
  67.              }
  68.             break;
  69.         case "WW-PhotosMenu": 
  70.             if (photosMenuOpen == false) 
  71.              {    document.getElementById('WW-PhotosMenu').style.display='none';
  72.                  document.getElementById('WW-PhotosMenuImg').src='../../Images/Links/PhotosOff.gif'; 
  73.              }
  74.              break;
  75.         case "WW-CamerasMenu": 
  76.               if (camerasMenuOpen == false) 
  77.              {    document.getElementById('WW-CamerasMenu').style.display='none';
  78.                  document.getElementById('WW-CamerasMenuImg').src='../../Images/Links/CamerasOff.gif'; 
  79.              }
  80.              break;            
  81.     }
  82. }
  83.  
  84. function hideAllMenus(menuName)
  85. {    if (menuName != "WW-NewsMenu") if (document.getElementById('WW-NewsMenu').style.display != 'none') hideMenu('WW-NewsMenu');
  86.     if (menuName != "WW-HealthMenu") if (document.getElementById('WW-HealthMenu').style.display != 'none') hideMenu('WW-HealthMenu');
  87.     if (menuName != "WW-VideosMenu") if (document.getElementById('WW-VideosMenu').style.display != 'none') hideMenu('WW-VideosMenu');
  88.     if (menuName != "WW-PhotosMenu") if (document.getElementById('WW-PhotosMenu').style.display != 'none') hideMenu('WW-PhotosMenu');
  89.     if (menuName != "WW-CamerasMenu") if (document.getElementById('WW-CamerasMenu').style.display != 'none') hideMenu('WW-CamerasMenu');
  90. }
  91.  
  92. function closeMenu(menuName, closeImmediately)
  93. {    closeImmediately = closeImmediately || false;
  94.     
  95.     if (closeImmediately == false)
  96.         setTimeout("hideMenu('" + menuName + "')", 500);
  97.     else
  98.         setTimeout("hideMenu('" + menuName + "')", 0);
  99. }
  100.  
  101.  
  102. //*******************
  103. //*  Skin Settings  *
  104. //*******************
  105. function loadSkinSettings()
  106. {    //****************************
  107.     //*  Load bar graph display  *
  108.     //****************************
  109.     switch (document.getElementById("WW-SkinOption7").innerHTML)
  110.     {    case "Hide":
  111.             document.getElementById("WW-Graphs").style.display = "none";
  112.             break;
  113.         default:    
  114.             if (document.getElementById("WW-Current-View").style.display == "")
  115.             {    document.getElementById("WW-Graphs").style.display = "";
  116.             }
  117.             
  118.             break;
  119.     }            
  120.     
  121.     //***************************
  122.     //*  Load news bar display  *
  123.     //***************************
  124.     switch (document.getElementById("WW-SkinOption4").innerHTML)
  125.     {    case "Hide":
  126.             document.getElementById("WW-News-Bar").style.display = "none";
  127.             break;
  128.         default:    
  129.             document.getElementById("WW-News-Bar").style.display = "";
  130.             break;
  131.     }            
  132.     
  133.     //*************************
  134.     //*  Load slider display  *
  135.     //*************************
  136.     document.getElementById("SliderDIV").style.left = "32px";
  137.  
  138.     try
  139.     {    switch (document.getElementById("WW-SkinOption2").innerHTML)
  140.         {    case "Days":
  141.                 document.getElementById("WW-Day-Slider").style.display = "";
  142.                 document.getElementById("WW-Moon-Slider").style.display = "none";
  143.                 document.getElementById("WW-Hour-Slider").style.display = "none";
  144.                 break;
  145.             case "Moons":
  146.                 document.getElementById("WW-Moon-Slider").style.display = "";
  147.                 document.getElementById("WW-Day-Slider").style.display = "none";
  148.                 document.getElementById("WW-Hour-Slider").style.display = "none";
  149.                 break;
  150.             default:    
  151.                 document.getElementById("WW-Moon-Slider").style.display = "none";
  152.                 
  153.                 switch (document.getElementById("WW-IsInternational").innerHTML)
  154.                 {    case "False":
  155.                         document.getElementById("WW-Day-Slider").style.display = "none";
  156.                         document.getElementById("WW-Hour-Slider").style.display = "";
  157.                         break;
  158.                     default:
  159.                         document.getElementById("WW-Day-Slider").style.display = "";
  160.                         document.getElementById("WW-Hour-Slider").style.display = "none";
  161.                         break;
  162.                 }    
  163.  
  164.                 break;
  165.         }        
  166.     }
  167.     catch(err){}    
  168.     
  169.     //****************************
  170.     //*  Load thermometer color  *
  171.     //****************************
  172.     switch (document.getElementById("WW-SkinOption1").innerHTML) 
  173.     {    case "Blue": 
  174.             document.getElementById("WW-Thermometer-Bulb").src = "../../Images/ThermBulbBlue.png";
  175.             document.getElementById("WW-Thermometer-Fill").style.background = "url('../../Images/ThermTopBlue.png') bottom";
  176.             break;
  177.         case "BlueRed":
  178.             if (parseInt(plainTemp) < 33)
  179.             {    document.getElementById("WW-Thermometer-Bulb").src = "../../Images/ThermBulbBlue.png";
  180.                 document.getElementById("WW-Thermometer-Fill").style.background = "url('../../Images/ThermTopBlue.png') bottom";
  181.             }
  182.             else
  183.             {    document.getElementById("WW-Thermometer-Bulb").src = "../../Images/ThermBulbRed.png";
  184.                 document.getElementById("WW-Thermometer-Fill").style.background = "url('../../Images/ThermTopRed.png') bottom";
  185.             }
  186.             
  187.             break;
  188.         case "RedBlue":
  189.             if (parseInt(plainTemp) < 33)
  190.             {    document.getElementById("WW-Thermometer-Bulb").style.background = "url('../../Images/ThermBulbRed.png')";
  191.                 document.getElementById("WW-Thermometer-Fill").style.background = "url('../../Images/ThermTopRed.png') bottom";
  192.             }
  193.             else
  194.             {    document.getElementById("WW-Thermometer-Bulb").src = "../../Images/ThermBulbBlue.png";
  195.                 document.getElementById("WW-Thermometer-Fill").style.background = "url('../../Images/ThermTopBlue.png') bottom";
  196.             }
  197.             
  198.             break;
  199.         default:
  200.             document.getElementById("WW-Thermometer-Bulb").src = "../../Images/ThermBulbRed.png";
  201.             document.getElementById("WW-Thermometer-Fill").style.background = "url('../../Images/ThermTopRed.png') bottom";
  202.             break;
  203.     }
  204.     
  205.     //***************************
  206.     //*  Load wind gauge arrow  *
  207.     //***************************
  208.     switch (document.getElementById("WW-SkinOption3").innerHTML)
  209.     {    case "Reverse": 
  210.             windArrowDirection = "R";
  211.             break;
  212.         default: 
  213.             windArrowDirection = "S";
  214.             break;
  215.     }
  216.     
  217.     //***************************************
  218.     //*  Set daily forecast more/less link  *
  219.     //***************************************
  220.     switch (document.getElementById("WW-SkinOption5").innerHTML)
  221.     {    case "More":
  222.             dailyForecastShowMore();
  223.             break;
  224.         default:
  225.             dailyForecastShowLess();
  226.             break;
  227.     }
  228. }
  229.  
  230.  
  231. //**********************************************************************************************************
  232. //*  The following functions are called from the Weather Watcher main window when the buttons are clicked  *
  233. //**********************************************************************************************************
  234. function displayCurrent()
  235. {    try
  236.     {    if (document.getElementById("WW-Current-View").style.display = "none")
  237.         {    showHideSlider(true);
  238.             showHideGauges(true);
  239.             
  240.             document.getElementById("WeatherBug-Logo").style.display = "";
  241.             
  242.             if (document.getElementById("WW-SkinOption7").innerHTML != "Hide")
  243.             {    document.getElementById("WW-Graphs").style.display = "";
  244.             }
  245.             
  246.             document.getElementById("WW-Status-Bar").style.display = "";
  247.             
  248.             document.getElementById("WW-Day-View").style.display = "none";
  249.             document.getElementById("WW-Current-View").style.display = "";
  250.             document.getElementById("WW-Hour-View").style.display = "none";
  251.         }        
  252.     }
  253.     catch(err){}                
  254. }
  255.  
  256. function displayHour()
  257. {    if (document.getElementById("WW-Hour-View").style.display = "none")
  258.     {    showHideSlider(false);
  259.         showHideGauges(false);
  260.                     
  261.         document.getElementById("WeatherBug-Logo").style.display = "none";
  262.         document.getElementById("WW-Graphs").style.display = "none";
  263.         document.getElementById("WW-Status-Bar").style.display = "none";
  264.         
  265.         document.getElementById("WW-Current-View").style.display = "none";
  266.         
  267.         switch (document.getElementById("WW-IsInternational").innerHTML)
  268.         {    case "False":
  269.                 document.getElementById("WW-Day-View").style.display = "none";
  270.                 document.getElementById("WW-Hour-View").style.display = "";        
  271.                 break;
  272.             default:
  273.                 document.getElementById("WW-Day-View").style.display = "";
  274.                 document.getElementById("WW-Hour-View").style.display = "none";
  275.                 break;
  276.         }        
  277.     }
  278. }
  279.  
  280. function displayDay()
  281. {    if (document.getElementById("WW-Day-View").style.display = "none")
  282.     {    showHideSlider(false);
  283.         showHideGauges(false);
  284.                     
  285.         document.getElementById("WeatherBug-Logo").style.display = "none";
  286.         document.getElementById("WW-Graphs").style.display = "none";
  287.         document.getElementById("WW-Status-Bar").style.display = "none";
  288.         
  289.         document.getElementById("WW-Current-View").style.display = "none";
  290.         document.getElementById("WW-Day-View").style.display = "";
  291.         document.getElementById("WW-Hour-View").style.display = "none";
  292.     }
  293. }
  294.  
  295.  
  296. //******************************
  297. //*  Daily forecast functions  *
  298. //******************************
  299. function dailyForecastShowMore()
  300. {    hideDIVs("WW-DailyLess");
  301.     hideDIVs("WW-DailyPrediction");
  302.     hideDIVs("WW-DailyConditionBold");
  303.     showDIVs("WW-DailyCondition");
  304.     showDIVs("WW-DailyMore");
  305.     
  306.     updateDIVs("WW-SkinOption5", "More");
  307.     setRunAction("SaveSkinSettings");
  308. }
  309.  
  310. function dailyForecastShowLess()
  311. {    hideDIVs("WW-DailyMore");
  312.     hideDIVs("WW-DailyCondition");
  313.     showDIVs("WW-DailyConditionBold");
  314.     showDIVs("WW-DailyLess");
  315.     showDIVs("WW-DailyPrediction");
  316.     
  317.     updateDIVs("WW-SkinOption5", "Less");
  318.     setRunAction("SaveSkinSettings");
  319. }
  320.  
  321.  
  322. //**********************
  323. //*  Slider functions  *
  324. //**********************
  325. function showHideSlider(makeVisible)
  326. {    if (makeVisible == true)
  327.     {    document.getElementById("SliderDIV").style.display = "";
  328.         document.getElementById("SliderEnd").style.display = "";
  329.     }
  330.     else
  331.     {    document.getElementById("SliderDIV").style.display = "none";
  332.         document.getElementById("SliderEnd").style.display = "none";
  333.     }
  334. }            
  335.  
  336. function resetSliderPosition()
  337. {    document.getElementById("SliderDIV").style.left = "32px";
  338. }
  339.  
  340. function showHideGauges(makeVisible)
  341. {    if (makeVisible == true)
  342.     {    document.getElementById("WW-Gauges").style.display = "";
  343.         document.getElementById("Right-Border").style.display = "none";
  344.     }
  345.     else
  346.     {    document.getElementById("WW-Gauges").style.display = "none";
  347.         document.getElementById("Right-Border").style.display = "";
  348.     }
  349. }
  350.  
  351.  
  352. //************************
  353. //*  Realtime functions  *
  354. //************************
  355. function refreshRealtimeData(updated, updatedTimeStamp, currentTemp, currentTempC, highTemp, highTempC, lowTemp, lowTempC, feelsLikeTemp, feelsLikeTempC, tempRate, tempRateC, wetBulb, wetBulbC, dewPoint, dewPointC, humidity, humidityHigh, humidityLow, humidityRate, rain, rainC, rainRate, rainRateC, rainRateMax, rainRateMaxC, rainMonth, rainMonthC, windDirection, windDirectionAvg, windSpeed, windSpeedC, windSpeedAvg, windSpeedAvgC, windGustDirection, windGust, windGustC, pressure, pressureC, pressureHigh, pressureHighC, pressureLow, pressureLowC, pressureRate, pressureRateC, tempDisplayBoth, tempDisplayPrimary, windInDegrees, localDecimalSep)
  356. {    updateDIVs("WW-Updated", updated);
  357.     updateDIVs("WW-Updated-Replaced", updated.replace("Observed","Updated"));
  358.     
  359.     graphLoad("WW-TempGraph", "Temperature", "-30", "130", lowTemp, iif((tempDisplayPrimary == "C"), lowTempC, lowTemp), currentTemp, iif(tempDisplayPrimary == "C", roundTemperature(currentTempC), roundTemperature(currentTemp)), highTemp, iif(tempDisplayPrimary == "C", highTempC, highTemp), "");
  360.     graphLoad("WW-PressureGraph", "Pressure", "27", "32", pressureLow, iif((pressureLowC != "N/A"), pressureLowC.replace(".",localDecimalSep), pressureLow.replace(".",localDecimalSep)), pressure, iif(pressureC != "N/A", pressureC.replace(".",localDecimalSep), pressure.replace(".",localDecimalSep)), pressureHigh, iif(pressureHighC != "N/A", pressureHighC.replace(".",localDecimalSep), pressureHigh.replace(".",localDecimalSep)), "");
  361.     graphLoad("WW-HumidityGraph", "Humidity", "-10", "120", humidityLow, humidityLow, humidity, humidity, humidityHigh, humidityHigh, "");
  362.     graphLoad("WW-WindGraph", "Wind", "-10", "60", "", "", windSpeed, iif((windSpeedC != "N/A"), windSpeedC, windSpeed), iif(windGust == "N/A", "", windGust), iif((windGustC != "N/A"), windGustC, iif(windGust == "N/A", "", windGust)), "");
  363.     
  364.     if (humidity != "N/A") humidity = humidity + "%";
  365.     if (humidityLow != "N/A") humidityLow = humidityLow + "%";
  366.     if (humidityHigh != "N/A") humidityHigh = humidityHigh + "%";
  367.     if (humidityRate != "N/A") humidityRate = humidityRate + "%";
  368.     
  369.     updateDIVs("WW-Barometer-Rate", pressureHigh);
  370.     updateDIVs("WW-CurrentHumidity", humidity);
  371.     updateDIVs("WW-HumidityLow", humidityLow);
  372.     updateDIVs("WW-HumidityHigh", humidityHigh);
  373.     updateDIVs("WW-HumidityRate", humidityRate);
  374.     updateDIVs("WW-WindDirectionAvg", windDirectionAvg);
  375.     updateDIVs("WW-WindGustDirection", windGustDirection);
  376.     
  377.     
  378.     document.getElementById("WW-BarometerGauge-Text").innerHTML = iif(pressureC != "N/A", pressureC.replace(".",localDecimalSep), pressure.replace(".",localDecimalSep));        
  379.     
  380.     
  381.     if (windDirectionAvg != "N/A") updateDIVs("WW-WindDegreesAvg", convertWindDirectionToDegrees(windDirectionAvg) + "°");    
  382.     else updateDIVs('WW-WindDegreesAvg', windDirection);    
  383.     
  384.     if (windGustC != "N/A") 
  385.     {    updateDIVs("WW-WindGust", windGustC);    
  386.     }
  387.     else 
  388.     {    updateDIVs("WW-WindGust", windGust);    
  389.     }
  390.     
  391.     if (pressureLowC != "N/A") updateDIVs("WW-BarometerLow", pressureLowC);
  392.     else updateDIVs("WW-BarometerLow", pressureLow);
  393.  
  394.     if (pressureHighC != "N/A") updateDIVs("WW-BarometerHigh", pressureHighC);
  395.     else updateDIVs("WW-BarometerHigh", pressureHigh);
  396.     
  397.     if (pressureRateC != "N/A") updateDIVs("WW-BarometeRate", pressureRateC);
  398.     else updateDIVs("WW-BarometerRate", pressureRate);
  399.  
  400.     refreshRealtimeTemps(currentTemp, currentTempC, highTemp, highTempC, lowTemp, lowTempC, feelsLikeTemp, feelsLikeTempC, tempRate, tempRateC, wetBulb, wetBulbC, dewPoint, dewPointC, tempDisplayBoth, tempDisplayPrimary);
  401.     
  402.     if (windSpeedC != "N/A") windSpeed = windSpeedC;
  403.     refreshRealtimeWindData(convertWindDirectionToDegrees(windDirection), windSpeed, feelsLikeTemp);
  404. }
  405.  
  406. function refreshRealtimeTemps(currentTemp, currentTempC, highTemp, highTempC, lowTemp, lowTempC, feelsLikeTemp, feelsLikeTempC, tempRate, tempRateC, wetBulb, wetBulbC, dewPoint, dewPointC, tempDisplayBoth, tempDisplayPrimary)
  407. {    if (tempDisplayPrimary == "C") 
  408.     {    updateTemperature(currentTempC + "°", currentTempC, highTempC, feelsLikeTempC);
  409.         
  410.         if (currentTempC != "N/A") 
  411.         {    if (tempDisplayBoth == false)
  412.             {    currentTempC = currentTempC + "°";
  413.             }
  414.             else
  415.             {    currentTempC = currentTempC + "°/" + currentTemp + "°";
  416.             }
  417.         }
  418.         
  419.         if (lowTempC != "N/A") 
  420.         {    if (tempDisplayBoth == false)
  421.             {    lowTempC = lowTempC + "°";
  422.             }
  423.             else
  424.             {    lowTempC = lowTempC + "°/" + lowTemp + "°";
  425.             }
  426.         }
  427.         
  428.         if (highTempC != "N/A") 
  429.         {    if (tempDisplayBoth == false)
  430.             {    highTempC = highTempC + "°";
  431.             }
  432.             else
  433.             {    highTempC = highTempC + "°/" + highTemp + "°";
  434.             }
  435.         }
  436.         
  437.         if (feelsLikeTempC != "N/A") 
  438.         {    if (tempDisplayBoth == false)
  439.             {    feelsLikeTempC = feelsLikeTempC + "°";
  440.             }
  441.             else
  442.             {    feelsLikeTempC = feelsLikeTempC + "°/" + feelsLikeTemp + "°";
  443.             }
  444.         }
  445.         
  446.         if (dewPointC != "N/A") 
  447.         {    if (tempDisplayBoth == false)
  448.             {    dewPointC = dewPointC + "°";
  449.             }
  450.             else
  451.             {    dewPointC = dewPointC + "°/" + dewPoint + "°";
  452.             }
  453.         }
  454.         
  455.         updateDIVs("WW-CurrentTemp", currentTempC);
  456.         updateDIVs("WW-TempLow", lowTempC);
  457.         updateDIVs("WW-TempHigh", highTempC);
  458.         
  459.         updateDIVs("WW-CurrentFeelsLikeTemp", feelsLikeTempC);
  460.         updateDIVs("WW-CurrentDew", dewPointC);
  461.     }
  462.     else
  463.     {    updateTemperature(currentTemp + "°", currentTemp, highTemp, feelsLikeTemp);
  464.         
  465.         if (currentTemp != "N/A") 
  466.         {    if (tempDisplayBoth == false)
  467.             {    currentTemp = currentTemp + "°";
  468.             }
  469.             else
  470.             {    currentTemp = currentTemp + "°/" + currentTempC + "°";
  471.             }
  472.         }
  473.         
  474.         if (lowTemp != "N/A") 
  475.         {    if (tempDisplayBoth == false)
  476.             {    lowTemp = lowTemp + "°";
  477.             }
  478.             else
  479.             {    lowTemp = lowTemp + "°/" + lowTempC + "°";
  480.             }
  481.         }
  482.         
  483.         if (highTemp != "N/A") 
  484.         {    if (tempDisplayBoth == false)
  485.             {    highTemp = highTemp + "°";
  486.             }
  487.             else
  488.             {    highTemp = highTemp + "°/" + highTempC + "°";
  489.             }
  490.         }
  491.         
  492.         if (feelsLikeTemp != "N/A") 
  493.         {    if (tempDisplayBoth == false)
  494.             {    feelsLikeTemp = feelsLikeTemp + "°";
  495.             }
  496.             else
  497.             {    feelsLikeTemp = feelsLikeTemp + "°/" + feelsLikeTempC + "°";
  498.             }
  499.         }
  500.         
  501.         if (dewPoint != "N/A") 
  502.         {    if (tempDisplayBoth == false)
  503.             {    dewPoint = dewPoint + "°";
  504.             }
  505.             else
  506.             {    dewPoint = dewPoint + "°/" + dewPointC + "°";
  507.             }    
  508.         }
  509.         
  510.         updateDIVs("WW-CurrentTemp", currentTemp);
  511.         updateDIVs("WW-TempLow", lowTemp);
  512.         updateDIVs("WW-TempHigh", highTemp);
  513.         
  514.         updateDIVs("WW-CurrentFeelsLikeTemp", feelsLikeTemp);
  515.         updateDIVs("WW-CurrentDew", dewPoint);
  516.     }
  517. }            
  518.  
  519. //*****************************
  520. //*  Realtime wind functions  *
  521. //*****************************
  522. function refreshRealtimeWindData(windDirection, windSpeed, windChill, windSpeedPlain, windChillPlain)
  523. {    var tmpWindSpeed = windSpeed.replace(",",".");
  524.  
  525.     if (isNaN(tmpWindSpeed)) 
  526.     {    windSpeed = "0"; 
  527.     }
  528.     else if (windSpeed == "NA")
  529.     {    windSpeed = "0"; 
  530.     }
  531.         
  532.     if (isNaN(windSpeedPlain)) 
  533.     {    windSpeedPlain = "0"; 
  534.     }
  535.     else if (windSpeedPlain == "NA")
  536.     {    windSpeedPlain = "0"; 
  537.     }
  538.     
  539.     //windSpeed = windSpeed.replace(",","");
  540.     
  541.     document.getElementById("WW-WindGauge-Text").innerHTML = windSpeed;        
  542.     
  543.     updateDIVs("WW-CurrentWind", windSpeed);    
  544.     updateDIVs("WW-CurrentWindDirection", convertWindDegreesToDirection(windDirection));
  545.     
  546.     graphLoad("WW-WindGraph", "Wind", "-10", "60", "", "", windSpeed, iif((windSpeed != windSpeedPlain), windSpeed, windSpeedPlain), "", "", "");
  547.     
  548.     windDirection = roundWindDirection(windDirection);
  549.                 
  550.     if (isNaN(lastWindDirection) || windDirection == lastWindDirection)
  551.     {    document.getElementById("WW-WindGauge-Image").src = "../../Images/Wind/" + windDirection + ".gif";
  552.     }
  553.     else 
  554.     {    var imageFileName = "../../Images/Wind/" + lastWindDirection + "-" + windDirection + ".gif";
  555.                         
  556.         if (imageExists(imageFileName) == true) document.getElementById("WW-WindGauge-Image").src = imageFileName + "?" + getUniqueNumber;
  557.         else document.getElementById("WW-WindGauge-Image").src = "../../Images/Wind/" + windDirection + ".gif";
  558.     } 
  559.     
  560.     lastWindDirection = windDirection;
  561. }
  562.  
  563.  
  564. function roundWindDirection(windDirection)
  565. {    var degree;
  566.  
  567.     if (windArrowDirection == "S")
  568.     {    windDirection = parseInt(windDirection) + 180;
  569.         if (windDirection > 359) windDirection = windDirection - 360;
  570.     }
  571.     
  572.     //*************************************************
  573.     //*  Round wind direction if not already rounded  *
  574.     //*************************************************
  575.     if (("|345|330|315|300|285|270|255|240|225|210|195|180|165|150|135|120|105|90|75|60|45|30|15|0|").indexOf("|" + windDirection + "|") == -1)
  576.     {    if (windDirection > 352) degree = 0;
  577.         else if (windDirection > 337) degree = 345;
  578.         else if (windDirection > 322) degree = 330;
  579.         else if (windDirection > 307) degree = 315;
  580.         else if (windDirection > 292) degree = 300;
  581.         else if (windDirection > 269) degree = 285;
  582.         else if (windDirection > 262) degree = 270;
  583.         else if (windDirection > 247) degree = 255;
  584.         else if (windDirection > 232) degree = 240;
  585.         else if (windDirection > 217) degree = 225;
  586.         else if (windDirection > 202) degree = 210;
  587.         else if (windDirection > 187) degree = 195;
  588.         else if (windDirection > 172) degree = 180;
  589.         else if (windDirection > 157) degree = 165;
  590.         else if (windDirection > 142) degree = 150;
  591.         else if (windDirection > 127) degree = 135;
  592.         else if (windDirection > 112) degree = 120;
  593.         else if (windDirection > 97) degree = 105;
  594.         else if (windDirection > 82) degree = 90;
  595.         else if (windDirection > 67) degree = 75;
  596.         else if (windDirection > 52) degree = 60;
  597.         else if (windDirection > 37) degree = 45;
  598.         else if (windDirection > 22) degree = 30;
  599.         else if (windDirection > 7) degree = 15;
  600.         else degree = 0;
  601.     }
  602.     else
  603.     {    degree = windDirection;
  604.     }
  605.     
  606.     return degree;
  607. }
  608.  
  609. function convertWindDegreesToDirection(windDegrees)
  610. {    var direction;
  611.  
  612.     if (windDegrees > 348.75) direction = "N";
  613.     else if (windDegrees > 326.25) direction = "NNW";
  614.     else if (windDegrees > 303.75) direction = "NW";
  615.     else if (windDegrees > 281.25) direction = "WNW";
  616.     else if (windDegrees > 258.75) direction = "W";
  617.     else if (windDegrees > 236.25) direction = "WSW";
  618.     else if (windDegrees > 213.75) direction = "SW";
  619.     else if (windDegrees > 191.25) direction = "SSW";
  620.     else if (windDegrees > 168.75) direction = "S";
  621.     else if (windDegrees > 146.25) direction = "SSE";
  622.     else if (windDegrees > 123.75) direction = "SE";
  623.     else if (windDegrees > 101.25) direction = "ESE";
  624.     else if (windDegrees > 78.75) direction = "E";
  625.     else if (windDegrees > 56.25) direction = "ENE";
  626.     else if (windDegrees > 33.75) direction = "NE";
  627.     else if (windDegrees > 11.25) direction = "NNE";
  628.     else direction = "N";
  629.     
  630.     return direction;
  631. }
  632.  
  633. function convertWindDirectionToDegrees(windDirection)
  634. {    switch(windDirection)
  635.     {    case "N": return "0"; break;    
  636.         case "NNE": return "23"; break;    
  637.         case "NE": return "45"; break;    
  638.         case "ENE": return "68"; break;    
  639.         case "E": return "90"; break;    
  640.         case "ESE": return "113"; break;    
  641.         case "SE": return "135"; break;    
  642.         case "SSE": return "158"; break;    
  643.         case "S": return "180"; break;    
  644.         case "SSE": return "158"; break;    
  645.         case "S": return "180"; break;    
  646.         case "SSW": return "203"; break;    
  647.         case "SW": return "225"; break;    
  648.         case "WSW": return "248"; break;    
  649.         case "W": return "270"; break;    
  650.         case "WNW": return "293"; break;    
  651.         case "NW": return "315"; break;    
  652.         default: return "0"; break;
  653.     }
  654. }
  655.  
  656. function roundTemperature(temp)
  657. {    if (temp != "NA")
  658.     {    temp = temp.replace(",",".");
  659.     
  660.         if (parseInt(temp).toString() != temp.toString())
  661.         {    if (temp > 0)
  662.             {    temp = parseFloat(temp) + 0.5;
  663.             }
  664.             else if (temp < 0)
  665.             {    temp = parseFloat(temp) - 0.5;
  666.             }
  667.         
  668.             temp = parseInt(temp);
  669.         }
  670.     }
  671.     
  672.     return temp;
  673. }
  674.  
  675.  
  676. function graphLoad(graphName, graphCaption, graphMinValue, graphMaxValue, barValue1, barCaption1, barValue2, barCaption2, barValue3, barCaption3, barValueSuffix)
  677. {    var graph = document.getElementById(graphName);
  678.     
  679.     if (graph)
  680.     {      document.getElementById(graphName + "-Caption").innerHTML = graphCaption;
  681.     
  682.         if (barValue1.length > 0) 
  683.         {      if (parseInt(barValue1) > parseInt(graphMaxValue)) barValue1 = graphMaxValue;
  684.             if (parseInt(barValue1) < parseInt(graphMinValue)) barValue1 = graphMinValue;
  685.         
  686.             graphSetBarValue(graphName + "-Bar1", graphMinValue, graphMaxValue, barValue1, barCaption1, barValueSuffix);
  687.         }
  688.         
  689.         if (barValue2.length > 0) 
  690.         {      if (parseInt(barValue2) > parseInt(graphMaxValue)) barValue2 = graphMaxValue;
  691.             if (parseInt(barValue2) < parseInt(graphMinValue)) barValue2 = graphMinValue;
  692.         
  693.             graphSetBarValue(graphName + "-Bar2", graphMinValue, graphMaxValue, barValue2, barCaption2, barValueSuffix);
  694.         }
  695.             
  696.         if (barValue3.length > 0) 
  697.         {      if (parseInt(barValue3) > parseInt(graphMaxValue)) barValue3 = graphMaxValue;
  698.             if (parseInt(barValue3) < parseInt(graphMinValue)) barValue3 = graphMinValue;
  699.     
  700.             graphSetBarValue(graphName + "-Bar3", graphMinValue, graphMaxValue, barValue3, barCaption3, barValueSuffix);
  701.         }
  702.     }
  703. }
  704.  
  705. function graphSetBarValue(graphBarName, graphMinValue, graphMaxValue, graphValue, graphCaption, graphValueSuffix)
  706. {    var graphBar = document.getElementById(graphBarName + "-Value");
  707.  
  708.     if (graphBar)
  709.     {    var barTop = document.getElementById(graphBarName + "-Top");
  710.         var barBottom = document.getElementById(graphBarName + "-Bottom");
  711.    
  712.         if (isNumeric(graphValue) == false) 
  713.         {    switch (parseInt(graphMinValue)) 
  714.             {    case -30: graphValue = -20; break;
  715.                 case -10: graphValue = 0; break;
  716.                 case 27: graphValue = 28; break;
  717.                 default: graphValue = graphMinValue; break;
  718.             }
  719.         
  720.             graphCaption = graphValue;
  721.         }
  722.        
  723.         if (graphValueSuffix == null) graphValueSuffix = "";
  724.        
  725.         var gHeight = parseInt(graphMaxValue) - parseInt(graphMinValue);
  726.         var gTopHeight = parseInt(graphMaxValue) - parseInt(graphValue);
  727.         var gBottomHeight = parseInt(graphValue) - parseInt(graphMinValue);
  728.        
  729.            barTop.style.height = 100 * (parseInt(gTopHeight) / parseInt(gHeight)) + "%";
  730.            barBottom.style.height = 100 * (parseInt(gBottomHeight) / parseInt(gHeight)) + "%";
  731.        
  732.            graphCaption = graphCaption.substring(0, 4);
  733.        
  734.            graphBar.innerHTML = graphCaption + graphValueSuffix;
  735.     }
  736. }
  737.  
  738. function getMapExtension()
  739. {    var strMapLink = document.getElementById("WW-SkinOption20").innerHTML + "";
  740.     var strMapLinkPrefix = "";
  741.     var strMapLinkExtension = "";
  742.         
  743.     if (strMapLink.length == 0)
  744.     {    return "jpg";
  745.     }
  746.     else
  747.     {    strMapLinkPrefix = left(strMapLink, 4).toLowerCase();
  748.         strMapLinkExtension = right(strMapLink, 3).toLowerCase();
  749.     
  750.         if (strMapLinkPrefix == "http" && ((strMapLinkExtension == "gif") || (strMapLinkExtension == "jpg") || (strMapLinkExtension == "png")))
  751.         {    return strMapLinkExtension;
  752.         }
  753.         else    
  754.         {    return "jpg";
  755.         }
  756.     }
  757. }